import { healthApis } from '@/api';

export const user = {
  namespaced: true,
  state() {
    return {
      // 主账户信息
      account: {},
    };
  },
  getters: {
    accountId: (state) => state.account?.id,
  },
  mutations: {
    setAccount(state, user) {
      state.account = user;
    },
  },
  actions: {
    async getAccount({ commit }) {
      const { account } = await healthApis.getMainAccount({ loading: false });
      commit('setAccount', account);
      return user;
    },
  },
};
